<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCheckin extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('checkin')) {
            return;
        }
        Schema::create('checkin', function (Blueprint $table) {
            $table->id();
            $table->string('checkin_address')->default('')->comment('签到地址');
            $table->string('checkout_address')->default('')->comment('签退地址');
            $table->string('checkin_img')->default('')->comment('签到图片');
            $table->string('checkout_img')->default('')->comment('签退图片');
            $table->string('check_status')->default('')->comment('签到状态');
            $table->string('checkin_time')->default('')->comment('签到时间');
            $table->string('checkout_time')->default('')->comment('签退时间');
            $table->string('rel_checkout_time')->default('')->comment('真实签退时间');
            $table->text('checkout_delay_desc')->nullable()->comment('签退延迟原因');
            $table->unsignedInteger('user_id')->default(0)->comment('签到用户id');
            $table->string('user_name')->default('')->comment('签到用户姓名');
            $table->integer('create_time')->nullable();
            $table->integer('update_time')->nullable();
        });

        Schema::create('checkin_work_order', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('checkin_id')->default(0);
            $table->unsignedInteger('work_order_id')->default(0);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('checkin');
    }
}
